

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>The styleSheet module &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../index.html" />
    <link rel="up" title="The qt module" href="mod_pyamp_ui_qt.html" />
    <link rel="next" title="The scrollableList module" href="pyamp_ui_qt_scrollableList.html" />
    <link rel="prev" title="The spacers module" href="pyamp_ui_qt_spacers.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_scrollableList.html" title="The scrollableList module"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_spacers.html" title="The spacers module"
             accesskey="P">previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui.html" >The ui module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui_qt.html" accesskey="U">The qt module</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <div class="section" id="module-pyamp.ui.qt.styleSheet">
<span id="the-stylesheet-module"></span><h1>The styleSheet module<a class="headerlink" href="#module-pyamp.ui.qt.styleSheet" title="Permalink to this headline">¶</a></h1>
<p>The styleSheet module contains the StyleSheet class which provides the
ability to more easily create a string for setting the style sheet of a
QWidget.</p>
<div class="section" id="the-stylesheet-class">
<h2>The StyleSheet class<a class="headerlink" href="#the-stylesheet-class" title="Permalink to this headline">¶</a></h2>
<p class="graphviz">
<img src="../_images/inheritance-bf4cbab6044d103a36ae612c6ba27b9782a8e4cb.png" alt="Inheritance diagram of pyamp.ui.qt.styleSheet.StyleSheet" usemap="#inheritance2259a03fa1" class="inheritance"/>
<map id="inheritance2259a03fa1" name="inheritance2259a03fa1">
<area shape="rect" href="#pyamp.ui.qt.styleSheet.StyleSheet" title="pyamp.ui.qt.styleSheet.StyleSheet" alt="" coords="5,7,248,33"/>
</map>
</p>
<dl class="class">
<dt id="pyamp.ui.qt.styleSheet.StyleSheet">
<em class="property">class </em><tt class="descclassname">pyamp.ui.qt.styleSheet.</tt><tt class="descname">StyleSheet</tt><big>(</big><em>widget=None</em>, <em>**kwargs</em><big>)</big><a class="reference internal" href="../_modules/pyamp/ui/qt/styleSheet.html#StyleSheet"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#pyamp.ui.qt.styleSheet.StyleSheet" title="Permalink to this definition">¶</a></dt>
<dd><p>The StyleSheet class provides a wrapper for <tt class="xref py py-class docutils literal"><span class="pre">PyQt4.QtGui.QWidget</span></tt>
style sheet strings. StyleSheets can be easily created an exported into a
string that is properly formatted for setting the style sheet of a
<tt class="xref py py-class docutils literal"><span class="pre">PyQt4.QtGui.QWidget</span></tt>.</p>
<p>Example:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">PyQt4.QtGui</span> <span class="kn">import</span> <span class="n">QApplication</span><span class="p">,</span> <span class="n">QWidget</span>
<span class="kn">from</span> <span class="nn">pyamp.ui.qt</span> <span class="kn">import</span> <span class="n">StyleSheet</span>

<span class="c"># Create the widget, and set its name</span>
<span class="n">app</span> <span class="o">=</span> <span class="n">QApplication</span><span class="p">([])</span>
<span class="n">widget</span> <span class="o">=</span> <span class="n">QWidget</span><span class="p">()</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setObjectName</span><span class="p">(</span><span class="s">&quot;ObjectName&quot;</span><span class="p">)</span>

<span class="c"># Create a simple style sheet</span>
<span class="n">style</span> <span class="o">=</span> <span class="n">StyleSheet</span><span class="p">(</span><span class="n">border</span><span class="o">=</span><span class="s">&quot;2px solid black&quot;</span><span class="p">)</span>
<span class="n">normal</span> <span class="o">=</span> <span class="s">&quot;border: 2px solid black&quot;</span>

<span class="c"># These calls are identical</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">style</span><span class="p">))</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="n">normal</span><span class="p">)</span>

<span class="c"># Create another style sheet, notice that underscores in the</span>
<span class="c"># StylSheet parameter names are converted to dashes in the</span>
<span class="c"># style sheet string</span>
<span class="n">style</span> <span class="o">=</span> <span class="n">StyleSheet</span><span class="p">(</span><span class="n">background_color</span><span class="o">=</span><span class="s">&quot;red&quot;</span><span class="p">,</span> <span class="n">color</span><span class="o">=</span><span class="s">&quot;blue&quot;</span><span class="p">,</span>
                   <span class="n">font_weight</span><span class="o">=</span><span class="s">&quot;bold&quot;</span><span class="p">)</span>
<span class="n">normal</span> <span class="o">=</span> <span class="s">&quot;background-color: red; color: blue; font-weight: bold&quot;</span>

<span class="c"># These calls are identical</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">style</span><span class="p">))</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="n">normal</span><span class="p">)</span>

<span class="c"># You can also specify a specific CSS selector string, which can be</span>
<span class="c"># either a specific string, or a widget. If given a widget, the</span>
<span class="c"># selector will be created using the object&#39;s class name (e.g.,</span>
<span class="c"># QWidget) and will append an ID selector with the object&#39;s name (if</span>
<span class="c"># and only if the widget is named).</span>
<span class="n">style1</span> <span class="o">=</span> <span class="n">StyleSheet</span><span class="p">(</span><span class="n">widget</span><span class="o">=</span><span class="s">&quot;QWidget#ObjectName&quot;</span><span class="p">,</span>
                    <span class="n">border</span><span class="o">=</span><span class="s">&quot;1px solid red&quot;</span><span class="p">,</span> <span class="n">margin_top</span><span class="o">=</span><span class="s">&quot;10&quot;</span><span class="p">)</span>
<span class="n">style2</span> <span class="o">=</span> <span class="n">StyleSheet</span><span class="p">(</span><span class="n">widget</span><span class="p">,</span> <span class="n">border</span><span class="o">=</span><span class="s">&quot;1px solid red&quot;</span><span class="p">,</span> <span class="n">margin_top</span><span class="o">=</span><span class="s">&quot;10&quot;</span><span class="p">)</span>
<span class="n">normal</span> <span class="o">=</span> <span class="s">&quot;QWidget#ObjectName { border: 1px solid red; margin-top: 10;&quot;</span>

<span class="c"># These calls are identical</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">style1</span><span class="p">))</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">style2</span><span class="p">))</span>
<span class="n">widget</span><span class="o">.</span><span class="n">setStyleSheet</span><span class="p">(</span><span class="n">normal</span><span class="p">)</span>
</pre></div>
</div>
<ul>
<li><dl class="first docutils">
<dt>widget &#8211; The widget selector for this style sheet. Can be either a</dt>
<dd><p class="first last">string, or an actual widget object</p>
</dd>
</dl>
</li>
<li><p class="first">kwargs &#8211; The keyword arguments</p>
</li>
</ul>
</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../index.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">The styleSheet module</a><ul>
<li><a class="reference internal" href="#the-stylesheet-class">The StyleSheet class</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="pyamp_ui_qt_spacers.html"
                        title="previous chapter">The spacers module</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="pyamp_ui_qt_scrollableList.html"
                        title="next chapter">The scrollableList module</a></p>
  <h3>This Page</h3>
  <ul class="this-page-menu">
    <li><a href="../_sources/_generated/pyamp_ui_qt_styleSheet.txt"
           rel="nofollow">Show Source</a></li>
  </ul>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_scrollableList.html" title="The scrollableList module"
             >next</a> |</li>
        <li class="right" >
          <a href="pyamp_ui_qt_spacers.html" title="The spacers module"
             >previous</a> |</li>
        <li><a href="../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="mod_pyamp.html" >The pyamp module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui.html" >The ui module</a> &raquo;</li>
          <li><a href="mod_pyamp_ui_qt.html" >The qt module</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>